package com.by.wx.util;

import com.by.wx.entity.Button;
import com.by.wx.entity.ClickButton;
import com.by.wx.entity.PhotoOrAlbumButton;
import com.by.wx.entity.SubButton;
import com.by.wx.entity.ViewButton;
import com.by.wx.service.WxService;

import net.sf.json.JSONObject;

public class CreateMenu {

	public static void main(String[] args) {
		Button btn = new Button();
		btn.getButton().add(new ClickButton("菜单点击", "1"));
		btn.getButton().add(new ViewButton("酒店注册", "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxfdd043128cf84acd&redirect_uri=http://h5.gzbaoya.cn/wxapp/wx/wxinRegiest.do&response_type=code&scope=snsapi_userinfo#wechat_redirect"));
		SubButton sb =new SubButton("有子菜单");
		sb.getSub_button().add(new PhotoOrAlbumButton("传图", "3-1"));
		sb.getSub_button().add(new ClickButton("点击", "3-2"));
		sb.getSub_button().add(new ViewButton("网易", "http://news.163.com"));
		btn.getButton().add(sb);
		JSONObject jsObject = JSONObject.fromObject(btn);
		String url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN";
		url = url.replace("ACCESS_TOKEN", WxService.getAccessToken());
		String reuslt = UtilsA.post(url, jsObject.toString());
		System.out.println(reuslt);
	}
}
